package InvocationHandler;

import java.lang.reflect.Proxy;

public class Main {
    public static void main(String[] args) {
        final Man man = new Man();
        PersonHandler invocationHandler = new PersonHandler();
        invocationHandler.setMain(man);

        Person pp = (Person) Proxy.newProxyInstance(Main.class.getClassLoader(),Man.class.getInterfaces(),invocationHandler);
        pp.sayHello();

        final Woman woman = new Woman();
        invocationHandler = new PersonHandler();
        invocationHandler.setMain(woman);


        pp = (Person) Proxy.newProxyInstance(Main.class.getClassLoader(),Woman.class.getInterfaces(),invocationHandler);
        pp.sayHello();
        LogPerson logPerson = new LogPerson();
        logPerson.setMain(woman);
        logPerson.sayHello();

    }
}
